import 'dart:async';
import 'dart:io';

import 'package:extended_plugin/src/keyboard.dart';
import 'package:extended_plugin/src/network.dart';
import 'package:extended_plugin/src/screen.dart';
import 'package:flutter/services.dart';

class ExtendedPlugin {
  static const MethodChannel _channel = const MethodChannel('extended_plugin');

  static const MethodChannel _displayChannel =
      MethodChannel('plugin_channel/pixel');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  /// 键盘变化事件
  static Stream<bool> get keyBoardOnChange$ => KeyBoardEvent.onChange$;

  static Stream<String> get screenShot$ => ScreenShotEvent.imagePath();

  static Stream<String> get networkStatus$ => NetWorkEvent.networkStatus();

  static Future<String?> getPixelChannel() async {
    if (Platform.isAndroid) {
      return await _displayChannel.invokeMethod('pixel');
    } else {
      return Future.value(null);
    }
  }
}
